package smartcampus.scjava.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import smartcampus.scjava.POJO.DO.Xinzitongji;
import smartcampus.scjava.POJO.DO.Xuesheng;

import java.util.Collection;
import java.util.List;

public interface XinzitongjiMapper {

    @Select("SELECT xinzi,count(*) num FROM xinzitongji GROUP BY xinzi")
    Collection<Object> findAllXinzi();

    @Select("SELECT count(*) num, xinzi FROM xinzitongji GROUP BY xinzi")
    Collection<Object> findAllNum();

    @Select("SELECT * FROM xinzitongji where xuehao like concat('%',#{xuehao},'%') and" +
            " xingming like concat('%',#{xingming},'%') ORDER BY id  DESC")
    List<Xinzitongji> selectAll(Xinzitongji xinzitongji);

    @Delete("DELETE FROM xinzitongji WHERE id = #{id}")
    void deleteById(Integer id);
    @Update("UPDATE xinzitongji SET xinzi=#{xinzi}, biyeshijian=#{biyeshijian} WHERE id = #{id}")
    void updateById(Xinzitongji xinzitongji);
    @Insert("INSERT INTO xinzitongji(xuehao, xingming, xinzi, biyeshijian) " +
            "VALUES(#{xuehao}, #{xingming}, #{xinzi}, #{biyeshijian})")
    void insert(Xinzitongji xinzitongji);

    @Select("SELECT xuehao FROM xinzitongji")
    List<String> selectAllXuehao();
}





